/*
 * @FilePath: \flutter_ducafecat_news_getx\lib\pages\main\widgets\catem.dart
 * @Date: 2022-07-14 11:05:02
 * @LastEditTime: 2022-07-14 14:28:13
 * @Description: 首页下的第二个分类栏，9个分类。使用forEach,注意和.map的区别
 */
import 'package:flutter/material.dart';
import 'package:flutter_ducafecat_news_getx/common/utils/iconfont.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class PraCategoriesWidget extends StatelessWidget {
  static const data = [
    '每日推荐',
    '私人FM',
    '歌单',
    '排行榜',
    '有声书',
    '数字专辑',
    '关注新歌',
    '歌房',
    '游戏专区',
  ];
  final dataIcon = [
    Icon(Icons.calendar_today_outlined,
        size: 25.sp, color: Color.fromARGB(255, 246, 91, 95)),
    Icon(Icons.radio, size: 25.sp, color: Color.fromARGB(255, 246, 91, 95)),
    Icon(Icons.queue_music,
        size: 25.sp, color: Color.fromARGB(255, 246, 91, 95)),
    Icon(Icons.assessment_outlined,
        size: 25.sp, color: Color.fromARGB(255, 246, 91, 95)),
    Icon(Icons.book_outlined,
        size: 25.sp, color: Color.fromARGB(255, 246, 91, 95)),
    Icon(Icons.headset_outlined,
        size: 25.sp, color: Color.fromARGB(255, 246, 91, 95)),
    Icon(Iconfont.chuangzuo,
        size: 25.sp, color: Color.fromARGB(255, 246, 91, 95)),
    Icon(Icons.star_border_purple500_rounded,
        size: 25.sp, color: Color.fromARGB(255, 246, 91, 95)),
    Icon(Icons.games_outlined,
        size: 25.sp, color: Color.fromARGB(255, 246, 91, 95))
  ];
  static const index = [0, 1, 2, 3, 4, 5, 6, 7, 8];
  final iconList = <Widget>[];
  List<Widget> IconMy() {
    index.forEach((i) {
      iconList.add(Container(
          alignment: Alignment.center,
          height: 60.h,
          width: 70.w,
          child: Column(
            children: [
              Container(
                height: 40.h,
                width: 40.h,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(20.h)),
                  color: Color.fromARGB(255, 240, 220, 220),
                ),
                child: dataIcon[i],
              ),
              Text(data[i],
                  style: TextStyle(
                      fontSize: 12.sp,
                      color: Color.fromARGB(255, 120, 120, 120)))
            ],
          )));
    });
    return iconList;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 60.h,
      child: SingleChildScrollView(
        scrollDirection: Axis.horizontal,
        reverse: true,
        padding: EdgeInsets.symmetric(horizontal: 10),
        child: Row(children: IconMy()),
      ),
    );
  }

  String colorString(Color color) =>
      "#${color.value.toRadixString(16).padLeft(8, '0').toUpperCase()}";
}
